﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Pibby.Core;
using Pibby.Core.IO;

namespace Pibby.UI
{
	public partial class SelectMediaDeviceForm : Form
	{
		public IDrive info; 

		public SelectMediaDeviceForm()
		{
			InitializeComponent();
		}

		private void SelectMediaDeviceForm_Load(object sender, EventArgs e)
		{
			IDriveCollection removableDrives = DriveDiscoverer.ListAllRemovableDrives();

			this.removableDriveListView.BeginUpdate();

			foreach (IDrive info in removableDrives)
			{
				ListViewItem item = this.removableDriveListView.Items.Add(info.Name);

				item.Tag = info;
				item.SubItems.Add(info.VolumeLabel);
				item.SubItems.Add(FileSizeInterpreter.InterpretSize (info.TotalSize));
			}

			this.removableDriveListView.EndUpdate();
		}

		private void removableDriveListView_SelectedIndexChanged(object sender, EventArgs e)
		{
			if (this.removableDriveListView.SelectedItems.Count > 0)
			{
				ListViewItem item = this.removableDriveListView.SelectedItems[0];

				string selected = item.Text;

				this.info = item.Tag as IDrive;
				// volume name
			}
		}
	}
}
